package com.weita.lightfood.service;


import com.weita.lightfood.model.dao.AddressDao;
import com.weita.lightfood.model.entity.Address;
import com.weita.lightfood.model.entity.School;
import com.weita.lightfood.model.query.address.AddAddrQuery;
import com.weita.lightfood.model.query.address.UpdateAddrQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author IT_Monster at 2019/04/12 13:23.
 */
@Service
public class AddressService {
    @Autowired
    AddressDao addressDao;

    /**
     * 添加地址
     * @param addAddrQuery
     * @return
     */
    public String addAddress(AddAddrQuery addAddrQuery) throws Exception {
        addressDao.addAddress(addAddrQuery);
        return "添加地址成功";
    }

    //删除地址
    public String deleteAddress(int addressId) throws Exception {
        addressDao.deleteAddress(addressId);
        return "删除地址成功";
    }

    //修改地址
    public String updateAddress(UpdateAddrQuery updateAddrQuery) throws Exception {
        addressDao.updateAddress(updateAddrQuery);
        return "修改地址成功";
    }

    //查询地址
    public List<Address> getAddress(int userId) throws Exception {
        return addressDao.getAddress(userId);
    }

    public List<School> getSchools() throws Exception {
        return addressDao.getSchools();
    }
}
